package com.baby.topics;

import com.baby.utils.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {

    public static void main(String[] args) throws IOException, TimeoutException {
        //连接对象
        Connection connection = ConnectionUtil.getConnection();
        //通道
        Channel channel = connection.createChannel();
        //路由
        channel.exchangeDeclare("topics_exchange","topic");
//        channel.exchangeDeclare("topics_exchange","topic",true);
        //发布
        channel.basicPublish("topics_exchange","lazy.orange.*", null,"通配符报道".getBytes());
//        channel.basicPublish("topics_exchange","lazy.orange.*", MessageProperties.PERSISTENT_TEXT_PLAIN,"通配符报道".getBytes());
        //释放资源
        channel.close();
        connection.close();
    }

}
